package neg;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class PedidoTest {
	@SuppressWarnings("unused")
	@Test
	public void validarPedidoNombre() {
		Pedido daError = null;
		try {
			daError = new Pedido("12/12/12", new Cliente("???", new Ubicacion(
					3, 4)));
		} catch (Exception e) {
			assertEquals(new IllegalArgumentException().toString(),
					e.toString());
		}
		try {
			daError = new Pedido("12/12/12", new Cliente("Julian", null));
		} catch (Exception e) {
			assertEquals(new IllegalArgumentException().toString(),
					e.toString());
		}
		try {
			daError = new Pedido("12/12/12", new Cliente("",
					new Ubicacion(2, 3)));
		} catch (Exception e) {
			assertEquals(new IllegalArgumentException().toString(),
					e.toString());
		}
		try {
			daError = new Pedido(null, new Cliente("Julian",
					new Ubicacion(2, 3)));
		} catch (Exception e) {
			assertEquals(new IllegalArgumentException().toString(),
					e.toString());
		}
		try {
			Pedido noDaErrores = new Pedido("12/12/12", new Cliente("Pedro",
					new Ubicacion(4.0, 5.2)));
			assertTrue(true);
		} catch (Exception e) {
			assertTrue(false);
		}
	}

	@Test
	public void validarClientesEquals() {
		Ubicacion ubicacion1 = new Ubicacion(4.0, 6.1);
		
		Cliente Pedro = new Cliente("Pedro", ubicacion1);
		Cliente copiaDePedro = new Cliente("Pedro", ubicacion1);
		Cliente Julian = new Cliente("Julian", new Ubicacion(4.0, 5.2));
		Cliente Pedrito = new Cliente("Pedro", new Ubicacion(1000.0, 5000.2));
		
		Pedido dePedro = new Pedido("12/12/12", Pedro);
		Pedido deCopiaDePedro = new Pedido("12/12/12", copiaDePedro);
		Pedido deJulian = new Pedido("12/12/12", Julian);
		Pedido dePedrito = new Pedido("12/12/12", Pedrito);
		
		assertEquals(dePedro, deCopiaDePedro);
		assertNotEquals(dePedro, deJulian);
		assertNotEquals(deCopiaDePedro, deJulian);
		assertNotEquals(dePedro, dePedrito);
		assertNotEquals(Julian, Pedrito);
	}
}
